import { useState, useEffect } from 'react'

const App = () => {
  const [count, setCount] = useState(0)

  // 副作用，依赖项是[]空数组 相当于：class组件的 componentDidMount
  // 初始化请求数据，全局事件的绑定 ....
  useEffect(() => {
    const handleResize = () => {
      console.log(window.innerWidth)
    }
    window.addEventListener('resize', handleResize)
  }, [])

  useEffect(() => {
    console.log('请求数据')
  }, [])

  return (
    <div className="app">
      App组件
      <hr />
      <div>
        <p>计数器：{count}</p>
        <button onClick={() => setCount(count + 1)}>+1</button>
      </div>
    </div>
  )
}

export default App